<?php
session_start();
echo"<script type = 'taxt/javascript' src = 'jquery-1.7.js'></script>";
echo"<script type='text/javascript' src='jquery-ui-1.8.16.custom.min.js'></script>";
echo"<link rel='stylesheet' type='text/css' href='jquery-ui-1.8.18.custom.css'>";
echo"<link rel='stylesheet' type='text/css' href='mainFrame.css'>";
mysql_connect("localhost", "sapmenet_admin", "a1s2d3f4g5h6j7") or die ("Problem with datebase");
mysql_select_db("sapmenet_users"); 
$snimka=mysql_query("SELECT put FROM pictures WHERE ID={$_POST['snID']}");
if (@mysql_num_rows($snimka)>0)
{
	$tyi=mysql_query("SELECT numberOfLikes, numberOfDislikes FROM pictures WHERE ID={$_POST['snID']}");
$snimka=mysql_result($snimka,0);
	echo"<div id='addCommentDiv'  title='Add comment'><center><img src='addCommentIcon.png' id='plusPic'></center></div>";
if ($_SESSION['JID']==$_SESSION['id'])
{
	while ($res=mysql_fetch_array($tyi, MYSQL_NUM))
	{
		echo"<div id = 'america'>";
		echo "<div id = 'likeAndDislikePanel'><img src = 'like.png' class = 'likePictureButton' id = '".$_POST['snID']."'> Likes: ".$res[0]."<img src = 'dislike.png' class = 'dislikePictureButton' id = '".$_POST['snID']."'> Dislikes: ".$res[1]."</div>";
		echo"<img src='Icons/close.png' id = '".$_POST['snID']."' class='delPicture'>";
		echo"<div class = 'clear'></div></div>";
	}
}
else
{
	while ($res=mysql_fetch_array($tyi, MYSQL_NUM))
	{
		echo"<div id = 'america'>";
		echo "<div id = 'likeAndDislikePanel'><img src = 'like.png' class = 'likePictureButton' id = '".$_POST['snID']."'> Likes: ".$res[0]."<img src = 'dislike.png' class = 'dislikePictureButton' id = '".$_POST['snID']."'> Dislikes: ".$res[1]."</div>";
		echo"<div class = 'clear'></div></div>";
	}
}
echo "<div id='snimka'><center><img src='".$snimka."' id='theSnimka'></center></div>";
echo"<div id = 'theCommentsDialog'><div id='commentsHeader'><h3>Comments</h3><img src='Icons/close.png' id='closeComments'></div><div id = 'commentsDialog'></div></div>";
echo "<script>
	";
	/*$('#comments').resizable({aspectRatio: 16 / 9, animate: true, ghost: true, alsoResize: '#headerLess'});
	$('#headerLess').resizable({animate: true, disabled: true, aspectRatio: 16 / 9});*/
echo"
	$(document).ready(function()
	{
		
	});
	$('#addCommentDiv').click(function()
	{
		var theId = $('.dislikePictureButton').attr('id');
		$('#theCommentsDialog').show('explode');
		$.post('showComments.php', {snID : theId}, function(ddata)
		{
			$('#commentsDialog').html(ddata);
		});
	});
	$('.likePictureButton').click(function()
	{
		$('.likePictureButton').removeClass('kopele');
		$(this).addClass('kopele');
		var theId = $('.kopele').attr('id');
		$.post('likePic.php', {picID : theId}, function(data)
		{
			$.post('showPic.php', {snID : theId}, function(marilyn)
			{
				$('#picture').html(marilyn);
			});
			$.post('showComments.php', {snID : theId}, function(ddata)
			{
				$('#commentsDialog').html(ddata);
			});
		});
	});
	$('.dislikePictureButton').click(function()
	{
		$('.dislikePictureButton').removeClass('kopele');
		$(this).addClass('kopele');
		var theId = $('.kopele').attr('id');
		$.post('dislikePic.php', {picID : theId}, function(data)
		{
			$.post('showPic.php', {snID : theId}, function(marilyn)
			{
				$('#picture').html(marilyn);
			});
			$.post('showComments.php', {snID : theId}, function(ddata)
			{
				$('#commentsDialog').html(ddata);
			});
		});
	});
	$('.delPicture').click(function()
	{
		if(confirm('Are you sure?') == true)
		{
			$('.delPicture').removeClass('konopa');
			$(this).addClass('konopa');
			var theId = $('.konopa').attr('id');
			$.post('deletePicture.php', {picID : theId}, function(data)
			{
				var curAlbum = ".$_SESSION['jalbum'].";
				$('#mainFrame').load('preview.php?album=' + curAlbum);
			});
		}
	});
	$('#closeComments').click(function()
	{
		$('#theCommentsDialog').hide('explode');
	});
</script>";
}
else 
{
	echo ("<div id = 'noPicturesInThisCurrentAlbumDiv'>There are no pictures in this album!</div>");
}
?>
































